﻿<div class="container">
		<h1>Tìm kiếm</h1>

		<div id = "top_reserve">
			<div id = "opt_box">
			</div>
			<div id = "add_new">
				<?php  
                    if( isset( $action )){
                        foreach($action as $a){
                            if( strtolower($a['id']) == 'new'){
                                echo anchor( base_url( ) . $a['url'], $a['label'] );
                                break;
                            }
                        }
                    } 
                        
                ?>
			</div>
		</div>


    <table id="hor-minimalist-b">
	<tr>
	  <?php

                foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) )
                        echo "<th>". $i[ 'label' ]."</th>";
                }
            ?>
            <th>Action</th>
	</tr>
	 <?php
                for( $i = 0; $i < count( $results ); $i++ ){
                    echo "<tr>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	        
         			                echo "<td>";
									if($item[ 'control' ] != "time")
										echo $results[ $i ][ $item[ 'field_id' ] ];
									else echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
            						echo "</td>";					
    					}?>
                         
                        <?php 
                            }
                        echo "<td>";
                            if( isset( $action ) ){
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'edit'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                                foreach($action as $a){
                                    if( strtolower($a['id']) == 'delete'){
                                        echo $results[ $i ][ $a['label'] ] . " ";
                                        break;
                                    }
                                }
                            }
                      
                            if( isset( $custom_action ) ){
                                
                                foreach( $custom_action as $item ){
                                //    $a = explode( '=', $item );
                                //    if( isset( $a[ 0 ] ) )
                                        echo $results[$i][$item['action_name']]. "  ";
                                }
                            }
                        echo "</td>";
                    echo "</tr>";
                }
            ?>
	</table>

</div>
